package com.test.miniotest.minio.utils;


import java.io.Serializable;

public class R<T> implements Serializable {

    private Integer code;

    private T data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    private String msg;


    public static <T> R<T> ok(T data){
        R<T> r = new R<>();
        r.setCode(200);
        r.setData(data);
        r.setMsg("ok");
        return r;
    }

    public static <T> R<T> ok(Integer code,T data){
        R<T> r = new R<>();
        r.setCode(code);
        r.setData(data);
        r.setMsg("ok");
        return r;
    }

    public static <T> R<T> ok(String msg){
        R<T> r = new R<>();
        r.setCode(200);
        r.setMsg(msg);
        return r;
    }

    public static <T> R<T> failed(String msg){
        R<T> r = new R<>();
        r.setCode(-1);
        r.setMsg(msg);
        return r;
    }

}
